// 基本用法
// class Animal {
//   move(dsitanceInMeters: number = 0) {
//     console.log(`Animal moved ${dsitanceInMeters}m.`);
//   }
// }
// class Dog extends Animal {
//   bark() {
//     console.log('worf! worf!');
//   }
// }
// const dog =  new Dog()
// dog.bark() // worf! worf!
// dog.move() // Animal moved 0m.
// dog.move(10) // Animal moved 10m.

// 继承父类， super关键字必须写在construct构造器的最前面
class Animal {
  name: string
  constructor(theName: string) {
    this.name = theName
  }
  move(dsitanceInMeters: number = 0) {
    console.log(`${this.name} moved ${dsitanceInMeters}m.`);
  }
}
enum Gender { male1 = 1, female1 = 2}
class Snake extends Animal {
  age: number
  gender: string
  constructor(name: string, age: number, gender: Gender) {
    super(name)
    this.age = age
    this.gender = Gender[gender]
  }
  move(distanceInMeters: number = 5) {
    console.log(`这${this.gender}蛇${this.age}很滑，走位风骚！！`)
    super.move(distanceInMeters)
  }
}
class Horse extends Animal {
  age: number
  gender: string
  constructor(age: number, gender: Gender) {
    super(name)
    this.age = age
    this.gender = Gender[gender]
  }
  move(distanceInMeters: number = 45) {
    console.log(`${this.gender}马弓手${this.age}关羽请求出战！！${this.name}`)
    super.move(distanceInMeters)
  }
}
let snake = new Snake('东皇太一', 19, 1)
snake.move(6)
// 这male1蛇19很滑，走位风骚！！
// 东皇太一 moved 6m.

let horse = new Horse(20, 2)
horse.move()
// female1马弓手20关羽请求出战！！
// moved 45m.